package com.module.sysconfig.controller;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.module.sysconfig.entity.Bdck;
import com.module.sysconfig.entity.Cyyjpz;
import com.module.sysconfig.entity.Ywlxpz;
import com.module.sysconfig.service.YwlxpzService;
import com.support.helper.AjaxHelper;
import com.support.util.StringUtils;
import com.support.web.ControllerSupport;
/**
 * 业务类型配置
 * @author 吕乐帅
 *
 */
@Controller
@Scope(value = "prototype")
@RequestMapping("/sysconfig/ywlxpz")
public class YwlxpzController extends ControllerSupport {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private YwlxpzService ywlxpzService;
	
	/**
	 * 新增业务类型数据
	 * @throws IOException
	 */
	@RequestMapping("/saveYwlxpz")
	 public void saveYwlxpz() throws IOException
	 {
		 try
		 	{
				Map<String, String>  paramsMap =  this.getParamsMap();
				Ywlxpz ywlxpz=new Ywlxpz();
				String QLLXID = paramsMap.get("QLLXID");
				String DJLXID = paramsMap.get("DJLXID");
				String YWLXMC = paramsMap.get("YWLXMC");
				String MS = paramsMap.get("MS");
				String SFQYQJ = paramsMap.get("SFQYQJ");
				String SFCF = paramsMap.get("SFCF");
				String SFDY = paramsMap.get("SFDY");
				String SFYY = paramsMap.get("SFYY");
				String SFGY = paramsMap.get("SFGY");
				String SFFZ = paramsMap.get("SFFZ");
				String SFDJ = paramsMap.get("SFDJ");
				String SFZX = paramsMap.get("SFZX");
				String QT = paramsMap.get("QT");
				String QJJKDZ = paramsMap.get("QJJKDZ");
				String CJR = paramsMap.get("CJR");
				String CJRMC = paramsMap.get("CJRMC");
				String ZHXGR = paramsMap.get("ZHXGR");
				String ZHXGRMC = paramsMap.get("ZHXGRMC");
				String SFLDKQ = paramsMap.get("SFLDKQ");
				String BZ1 = paramsMap.get("BZ1");
				String BZ2 = paramsMap.get("BZ2");
				String BZ3 = paramsMap.get("BZ3");
				String BZ4 = paramsMap.get("BZ4");
				
				
				ywlxpz.setQllxid(QLLXID ==null ? "": QLLXID);
				ywlxpz.setDjlxid(DJLXID ==null ? "": DJLXID);
				ywlxpz.setYwlxmc(YWLXMC ==null ? "": YWLXMC);
				ywlxpz.setMs(MS ==null ? "": MS);
				ywlxpz.setSfqyqj(SFQYQJ ==null ? "": SFQYQJ);
				ywlxpz.setSfcf(SFCF ==null ? "": SFCF);
				ywlxpz.setSfdy(SFDY ==null ? "": SFDY);
				ywlxpz.setSfyy(SFYY ==null ? "": SFYY);
				ywlxpz.setSfgy(SFGY ==null ? "": SFGY);
				ywlxpz.setSffz(SFFZ ==null ? "": SFFZ);
				ywlxpz.setSfdj(SFDJ ==null ? "": SFDJ);
				ywlxpz.setSfzx(SFZX ==null ? "": SFZX);
				ywlxpz.setQt(QT ==null ? "": QT);
				ywlxpz.setQjjkdz(QJJKDZ ==null ? "": QJJKDZ);
				ywlxpz.setCjr(CJR ==null ? "": CJR);
				ywlxpz.setCjrmc(CJRMC ==null ? "": CJRMC);
				ywlxpz.setZhxgr(ZHXGR ==null ? "": ZHXGR);
				ywlxpz.setZhxgrmc(ZHXGRMC ==null ? "": ZHXGRMC);
				ywlxpz.setSfldkq(SFLDKQ ==null ? "": SFLDKQ);
				ywlxpz.setSfhf(1);
				ywlxpz.setBz1(BZ1 == null ? "":BZ1);
				ywlxpz.setBz2(BZ2 == null ? "":BZ2);
				ywlxpz.setBz3(BZ3 == null ? "":BZ3);
				ywlxpz.setBz4(BZ4 == null ? "":BZ4);
				
				 ywlxpzService.saveYwlxpz(ywlxpz);
				
				 returnJSONView(AjaxHelper.toJSON(ywlxpz, AjaxHelper.SUCCESS, "新增业务类型数据成功"));
	 }catch (Exception e)
	 	{
			e.printStackTrace();
			logger.error("YwlxpzController.saveYwlxpz:", e);
			returnJSONView(AjaxHelper.toJSON(null, AjaxHelper.FAILURE, e.getMessage()));
		}
	 }
	
	/**
	 * 修改业务类型数据
	 * @throws IOException
	 */
	 @RequestMapping("/updateYwlxpz")
	 public void updateYwlxpz() throws IOException
	 {
		 try{
			 Map<String, String>  paramsMap =  this.getParamsMap();
			 String id = paramsMap.get("ID");
				if(StringUtils.isEmpty(id))
				{
					returnJSONView(AjaxHelper.toJSON(null, AjaxHelper.FAILURE, "缺少主键ID"));
					return;
				}
				Ywlxpz ywlxpz =ywlxpzService.queryYwlxpzById(Long.parseLong(id));//根据ID查询数据
				String QLLXID = paramsMap.get("QLLXID");
				String DJLXID = paramsMap.get("DJLXID");
				String YWLXMC = paramsMap.get("YWLXMC");
				String MS = paramsMap.get("MS");
				String SFQYQJ = paramsMap.get("SFQYQJ");
				String SFCF = paramsMap.get("SFCF");
				String SFDY = paramsMap.get("SFDY");
				String SFYY = paramsMap.get("SFYY");
				String SFGY = paramsMap.get("SFGY");
				String SFFZ = paramsMap.get("SFFZ");
				String SFDJ = paramsMap.get("SFDJ");
				String SFZX = paramsMap.get("SFZX");
				String QT = paramsMap.get("QT");
				String QJJKDZ = paramsMap.get("QJJKDZ");
				String CJR = paramsMap.get("CJR");
				String CJRMC = paramsMap.get("CJRMC");
				String CJSJ = paramsMap.get("CJSJ");
				String ZHXGR = paramsMap.get("ZHXGR");
				String ZHXGRMC = paramsMap.get("ZHXGRMC");
				String ZHXGSJ = paramsMap.get("ZHXGSJ");
				String SFLDKQ = paramsMap.get("SFLDKQ");
				String BZ1 = paramsMap.get("BZ1");
				String BZ2 = paramsMap.get("BZ2");
				String BZ3 = paramsMap.get("BZ3");
				String BZ4 = paramsMap.get("BZ4");
				
				ywlxpz.setQllxid(QLLXID ==null ? "": QLLXID);
				ywlxpz.setDjlxid(DJLXID ==null ? "": DJLXID);
				ywlxpz.setYwlxmc(YWLXMC ==null ? "": YWLXMC);
				ywlxpz.setMs(MS ==null ? "": MS);
				ywlxpz.setSfqyqj(SFQYQJ ==null ? "": SFQYQJ);
				ywlxpz.setSfcf(SFCF ==null ? "": SFCF);
				ywlxpz.setSfdy(SFDY ==null ? "": SFDY);
				ywlxpz.setSfyy(SFYY ==null ? "": SFYY);
				ywlxpz.setSfgy(SFGY ==null ? "": SFGY);
				ywlxpz.setSffz(SFFZ ==null ? "": SFFZ);
				ywlxpz.setSfdj(SFDJ ==null ? "": SFDJ);
				ywlxpz.setSfzx(SFZX ==null ? "": SFZX);
				ywlxpz.setQt(QT ==null ? "": QT);
				ywlxpz.setQjjkdz(QJJKDZ ==null ? "": QJJKDZ);
				ywlxpz.setCjr(CJR ==null ? "": CJR);
				ywlxpz.setCjrmc(CJRMC ==null ? "": CJRMC);
				ywlxpz.setZhxgr(ZHXGR ==null ? "": ZHXGR);
				ywlxpz.setZhxgrmc(ZHXGRMC ==null ? "": ZHXGRMC);
				ywlxpz.setSfldkq(SFLDKQ ==null ? "": SFLDKQ);
				ywlxpz.setSfhf(1);
				ywlxpz.setBz1(BZ1 == null ? "":BZ1);
				ywlxpz.setBz2(BZ2 == null ? "":BZ2);
				ywlxpz.setBz3(BZ3 == null ? "":BZ3);
				ywlxpz.setBz4(BZ4 == null ? "":BZ4);
		 
				ywlxpzService.updateYwlxpz(ywlxpz);
				returnJSONView(AjaxHelper.toJSON(ywlxpz, AjaxHelper.SUCCESS, "业务类型数据更新成功"));
	 }catch (Exception e)
	 	{
			e.printStackTrace();
			logger.error("YwlxpController.updateCyyjpz:", e);
			returnJSONView(AjaxHelper.toJSON(null, AjaxHelper.FAILURE, e.getMessage()));
		}
	 }
	 
	 /**
	  * 删除业务类型数据
	  * @throws IOException
	  */
	 @RequestMapping("/deleteYwlxpz")
		public void deleteYwlxpz() throws IOException
		{
			try{
				Map<String, String> paramsMap = this.getParamsMap();
				String id = paramsMap.get("ID");
				if(null == id)
				{
					returnJSONView(AjaxHelper.toJSON(null, AjaxHelper.FAILURE, "缺少主键ID"));
					return;
				}
				ywlxpzService.deleteYwlxpz(Long.parseLong(id));
				returnJSONView(AjaxHelper.toJSON(null, AjaxHelper.SUCCESS, "删除业务类型数据成功！"));
				
			}catch (Exception e) 
			{
				e.printStackTrace();
				logger.error("YwlxpController.deleteYwlxpz:", e);
				returnJSONView(AjaxHelper.toJSON(null, AjaxHelper.FAILURE, e.getMessage()));
			}
		}
	 
	 /**
	  * 查询业务类型数据
	  * @throws IOException
	  */
	 @RequestMapping("/queryYwlexpz")
		public void queryYwlexpz() throws IOException
		{
			try{
				
				List<Map<String, String>> bdckList = ywlxpzService.queryYwlxpz();
				returnJSONView(AjaxHelper.toJSON(bdckList, AjaxHelper.SUCCESS, "表单仓库数据查询！"));
				
			}catch (Exception e) {
				e.printStackTrace();
				logger.error("ywlxpzController.saveYwlxpz:", e);
				returnJSONView(AjaxHelper.toJSON(null, AjaxHelper.FAILURE, e.getMessage()));
			}
		}
	 
	 
	 /**
	  * 按ID查询业务类型数据
	  * @throws IOException
	  */
	 @RequestMapping("/queryYwlxpzById")
		public void queryYwlxpzById() throws IOException
		{
			try{
				Map<String, String> paramsMap = this.getParamsMap();
				
				String ID = paramsMap.get("ID");
				if(StringUtils.isNumeric(ID)){
				returnJSONView(AjaxHelper.toJSON(ywlxpzService.queryYwlxpzById(Long.parseLong(ID)), AjaxHelper.SUCCESS, "业务类型数据查询！"));
				}
			}catch (Exception e) {
				e.printStackTrace();
				logger.error("ywlxpzController.saveYwlxpz:", e);
				returnJSONView(AjaxHelper.toJSON(null, AjaxHelper.FAILURE, e.getMessage()));
			}
		}
}
